<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/xml/qdom.cpp -->
<head>
  <title>Qt 4.3: QDomDocument Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QDomDocument Class Reference<br /><sup><sup>[<a href="qtxml.html">QtXml</a> module]</sup></sup></h1>
<p>The QDomDocument class represents an XML document. <a href="#details">More...</a></p>
<pre> #include &lt;QDomDocument&gt;</pre><p>Inherits <a href="qdomnode.html">QDomNode</a>.</p>
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qdomdocument-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qdomdocument.html#QDomDocument">QDomDocument</a></b> ()</li>
<li><div class="fn"/><b><a href="qdomdocument.html#QDomDocument-2">QDomDocument</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/><b><a href="qdomdocument.html#QDomDocument-3">QDomDocument</a></b> ( const QDomDocumentType &amp; <i>doctype</i> )</li>
<li><div class="fn"/><b><a href="qdomdocument.html#QDomDocument-4">QDomDocument</a></b> ( const QDomDocument &amp; <i>x</i> )</li>
<li><div class="fn"/><b><a href="qdomdocument.html#dtor.QDomDocument">~QDomDocument</a></b> ()</li>
<li><div class="fn"/>QDomAttr <b><a href="qdomdocument.html#createAttribute">createAttribute</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>QDomAttr <b><a href="qdomdocument.html#createAttributeNS">createAttributeNS</a></b> ( const QString &amp; <i>nsURI</i>, const QString &amp; <i>qName</i> )</li>
<li><div class="fn"/>QDomCDATASection <b><a href="qdomdocument.html#createCDATASection">createCDATASection</a></b> ( const QString &amp; <i>value</i> )</li>
<li><div class="fn"/>QDomComment <b><a href="qdomdocument.html#createComment">createComment</a></b> ( const QString &amp; <i>value</i> )</li>
<li><div class="fn"/>QDomDocumentFragment <b><a href="qdomdocument.html#createDocumentFragment">createDocumentFragment</a></b> ()</li>
<li><div class="fn"/>QDomElement <b><a href="qdomdocument.html#createElement">createElement</a></b> ( const QString &amp; <i>tagName</i> )</li>
<li><div class="fn"/>QDomElement <b><a href="qdomdocument.html#createElementNS">createElementNS</a></b> ( const QString &amp; <i>nsURI</i>, const QString &amp; <i>qName</i> )</li>
<li><div class="fn"/>QDomEntityReference <b><a href="qdomdocument.html#createEntityReference">createEntityReference</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>QDomProcessingInstruction <b><a href="qdomdocument.html#createProcessingInstruction">createProcessingInstruction</a></b> ( const QString &amp; <i>target</i>, const QString &amp; <i>data</i> )</li>
<li><div class="fn"/>QDomText <b><a href="qdomdocument.html#createTextNode">createTextNode</a></b> ( const QString &amp; <i>value</i> )</li>
<li><div class="fn"/>QDomDocumentType <b><a href="qdomdocument.html#doctype">doctype</a></b> () const</li>
<li><div class="fn"/>QDomElement <b><a href="qdomdocument.html#documentElement">documentElement</a></b> () const</li>
<li><div class="fn"/>QDomElement <b><a href="qdomdocument.html#elementById">elementById</a></b> ( const QString &amp; <i>elementId</i> )</li>
<li><div class="fn"/>QDomNodeList <b><a href="qdomdocument.html#elementsByTagName">elementsByTagName</a></b> ( const QString &amp; <i>tagname</i> ) const</li>
<li><div class="fn"/>QDomNodeList <b><a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a></b> ( const QString &amp; <i>nsURI</i>, const QString &amp; <i>localName</i> )</li>
<li><div class="fn"/>QDomImplementation <b><a href="qdomdocument.html#implementation">implementation</a></b> () const</li>
<li><div class="fn"/>QDomNode <b><a href="qdomdocument.html#importNode">importNode</a></b> ( const QDomNode &amp; <i>importedNode</i>, bool <i>deep</i> )</li>
<li><div class="fn"/>QDomNode::NodeType <b><a href="qdomdocument.html#nodeType">nodeType</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent">setContent</a></b> ( const QByteArray &amp; <i>data</i>, bool <i>namespaceProcessing</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-2">setContent</a></b> ( const QString &amp; <i>text</i>, bool <i>namespaceProcessing</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-3">setContent</a></b> ( QIODevice * <i>dev</i>, bool <i>namespaceProcessing</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-4">setContent</a></b> ( const QString &amp; <i>text</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-5">setContent</a></b> ( const QByteArray &amp; <i>buffer</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-6">setContent</a></b> ( QIODevice * <i>dev</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>bool <b><a href="qdomdocument.html#setContent-7">setContent</a></b> ( QXmlInputSource * <i>source</i>, QXmlReader * <i>reader</i>, QString * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</li>
<li><div class="fn"/>QByteArray <b><a href="qdomdocument.html#toByteArray">toByteArray</a></b> ( int <i>indent</i> = 1 ) const</li>
<li><div class="fn"/>QString <b><a href="qdomdocument.html#toString">toString</a></b> ( int <i>indent</i> = 1 ) const</li>
<li><div class="fn"/>QDomDocument &amp; <b><a href="qdomdocument.html#operator-eq">operator=</a></b> ( const QDomDocument &amp; <i>x</i> )</li>
</ul>
<ul>
<li><div class="fn"/>66 public functions inherited from <a href="qdomnode.html#public-functions">QDomNode</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QDomDocument class represents an XML document.</p>
<p>The QDomDocument class represents the entire XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.</p>
<p>Since elements, text nodes, comments, processing instructions, etc., cannot exist outside the context of a document, the document class also contains the factory functions needed to create these objects. The node objects created have an <a href="qdomnode.html#ownerDocument">ownerDocument</a>() function which associates them with the document within whose context they were created. The DOM classes that will be used most often are <a href="qdomnode.html">QDomNode</a>, QDomDocument, <a href="qdomelement.html">QDomElement</a> and <a href="qdomtext.html">QDomText</a>.</p>
<p>The parsed XML is represented internally by a tree of objects that can be accessed using the various QDom classes. All QDom classes only <i>reference</i> objects in the internal tree. The internal objects in the DOM tree will get deleted once the last QDom object referencing them and the QDomDocument itself are deleted.</p>
<p>Creation of elements, text nodes, etc. is done using the various factory functions provided in this class. Using the default constructors of the QDom classes will only result in empty objects that cannot be manipulated or inserted into the Document.</p>
<p>The QDomDocument class has several functions for creating document data, for example, <a href="qdomdocument.html#createElement">createElement</a>(), <a href="qdomdocument.html#createTextNode">createTextNode</a>(), <a href="qdomdocument.html#createComment">createComment</a>(), <a href="qdomdocument.html#createCDATASection">createCDATASection</a>(), <a href="qdomdocument.html#createProcessingInstruction">createProcessingInstruction</a>(), <a href="qdomdocument.html#createAttribute">createAttribute</a>() and <a href="qdomdocument.html#createEntityReference">createEntityReference</a>(). Some of these functions have versions that support namespaces, i.e&#x2e; <a href="qdomdocument.html#createElementNS">createElementNS</a>() and <a href="qdomdocument.html#createAttributeNS">createAttributeNS</a>(). The <a href="qdomdocument.html#createDocumentFragment">createDocumentFragment</a>() function is used to hold parts of the document; this is useful for manipulating for complex documents.</p>
<p>The entire content of the document is set with <a href="qdomdocument.html#setContent">setContent</a>(). This function parses the string it is passed as an XML document and creates the DOM tree that represents the document. The root element is available using <a href="qdomdocument.html#documentElement">documentElement</a>(). The textual representation of the document can be obtained using <a href="qdomdocument.html#toString">toString</a>().</p>
<p>It is possible to insert a node from another document into the document using <a href="qdomdocument.html#importNode">importNode</a>().</p>
<p>You can obtain a list of all the elements that have a particular tag with <a href="qdomdocument.html#elementsByTagName">elementsByTagName</a>() or with <a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a>().</p>
<p>The QDom classes are typically used as follows:</p>
<pre> QDomDocument doc(&quot;mydocument&quot;);
 QFile file(&quot;mydocument.xml&quot;);
 if (!file.open(QIODevice::ReadOnly))
     return;
 if (!doc.setContent(&amp;file)) {
     file.close();
     return;
 }
 file.close();

<span class="comment"> //</span> print out the element names of all elements that are direct children
<span class="comment"> //</span> of the outermost element.
 QDomElement docElem = doc.documentElement();

 QDomNode n = docElem.firstChild();
 while(!n.isNull()) {
     QDomElement e = n.toElement(); <span class="comment">//</span> try to convert the node to an element.
     if(!e.isNull()) {
         cout &lt;&lt; e.tagName() &lt;&lt; endl; <span class="comment">//</span> the node really is an element.
     }
     n = n.nextSibling();
 }

<span class="comment"> //</span> Here we append a new element to the end of the document
 QDomElement elem = doc.createElement(&quot;img&quot;);
 elem.setAttribute(&quot;src&quot;, &quot;myimage.png&quot;);
 docElem.appendChild(elem);</pre>
<p>Once <tt>doc</tt> and <tt>elem</tt> go out of scope, the whole internal tree representing the XML document is deleted.</p>
<p>To create a document using DOM use code like this:</p>
<pre> QDomDocument doc(&quot;MyML&quot;);
 QDomElement root = doc.createElement(&quot;MyML&quot;);
 doc.appendChild(root);

 QDomElement tag = doc.createElement(&quot;Greeting&quot;);
 root.appendChild(tag);

 QDomText t = doc.createTextNode(&quot;Hello World&quot;);
 tag.appendChild(t);

 QString xml = doc.toString();</pre>
<p>For further information about the Document Object Model see the Document Object Model (DOM) <a href="http://www.w3.org/TR/REC-DOM-Level-1/">Level 1</a> and <a href="http://www.w3.org/TR/DOM-Level-2-Core/">Level 2 Core</a> Specifications.</p>
<p>See also <a href="xml-dombookmarks.html">DOM Bookmarks Example</a> and <a href="itemviews-simpledommodel.html">Simple DOM Model Example</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QDomDocument"></a>QDomDocument::QDomDocument ()</h3>
<p>Constructs an empty document.</p>
<h3 class="fn"><a name="QDomDocument-2"></a>QDomDocument::QDomDocument ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Creates a document and sets the name of the document type to <i>name</i>.</p>
<h3 class="fn"><a name="QDomDocument-3"></a>QDomDocument::QDomDocument ( const <a href="qdomdocumenttype.html">QDomDocumentType</a> &amp; <i>doctype</i> )</h3>
<p>Creates a document with the document type <i>doctype</i>.</p>
<p>See also <a href="qdomimplementation.html#createDocumentType">QDomImplementation::createDocumentType</a>().</p>
<h3 class="fn"><a name="QDomDocument-4"></a>QDomDocument::QDomDocument ( const QDomDocument &amp; <i>x</i> )</h3>
<p>Constructs a copy of <i>x</i>.</p>
<p>The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use <a href="qdomnode.html#cloneNode">cloneNode</a>().</p>
<h3 class="fn"><a name="dtor.QDomDocument"></a>QDomDocument::~QDomDocument ()</h3>
<p>Destroys the object and frees its resources.</p>
<h3 class="fn"><a name="createAttribute"></a><a href="qdomattr.html">QDomAttr</a> QDomDocument::createAttribute ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Creates a new attribute called <i>name</i> that can be inserted into an element, e.g&#x2e; using <a href="qdomelement.html#setAttributeNode">QDomElement::setAttributeNode</a>().</p>
<p>If <i>name</i> is not a valid XML name, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomdocument.html#createAttributeNS">createAttributeNS</a>().</p>
<h3 class="fn"><a name="createAttributeNS"></a><a href="qdomattr.html">QDomAttr</a> QDomDocument::createAttributeNS ( const <a href="qstring.html">QString</a> &amp; <i>nsURI</i>, const <a href="qstring.html">QString</a> &amp; <i>qName</i> )</h3>
<p>Creates a new attribute with namespace support that can be inserted into an element. The name of the attribute is <i>qName</i> and the namespace URI is <i>nsURI</i>. This function also sets <a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values (depending on <i>qName</i>).</p>
<p>If <i>qName</i> is not a valid XML name, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomdocument.html#createAttribute">createAttribute</a>().</p>
<h3 class="fn"><a name="createCDATASection"></a><a href="qdomcdatasection.html">QDomCDATASection</a> QDomDocument::createCDATASection ( const <a href="qstring.html">QString</a> &amp; <i>value</i> )</h3>
<p>Creates a new CDATA section for the string <i>value</i> that can be inserted into the document, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored in a CDATA section, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().</p>
<h3 class="fn"><a name="createComment"></a><a href="qdomcomment.html">QDomComment</a> QDomDocument::createComment ( const <a href="qstring.html">QString</a> &amp; <i>value</i> )</h3>
<p>Creates a new comment for the string <i>value</i> that can be inserted into the document, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored in an XML comment, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().</p>
<h3 class="fn"><a name="createDocumentFragment"></a><a href="qdomdocumentfragment.html">QDomDocumentFragment</a> QDomDocument::createDocumentFragment ()</h3>
<p>Creates a new document fragment, that can be used to hold parts of the document, e.g&#x2e; when doing complex manipulations of the document tree.</p>
<h3 class="fn"><a name="createElement"></a><a href="qdomelement.html">QDomElement</a> QDomDocument::createElement ( const <a href="qstring.html">QString</a> &amp; <i>tagName</i> )</h3>
<p>Creates a new element called <i>tagName</i> that can be inserted into the DOM tree, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().</p>
<p>If <i>tagName</i> is not a valid XML name, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p><a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>()</p>
<p>See also <a href="qdomdocument.html#createElementNS">createElementNS</a>(), <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), and <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>().</p>
<h3 class="fn"><a name="createElementNS"></a><a href="qdomelement.html">QDomElement</a> QDomDocument::createElementNS ( const <a href="qstring.html">QString</a> &amp; <i>nsURI</i>, const <a href="qstring.html">QString</a> &amp; <i>qName</i> )</h3>
<p>Creates a new element with namespace support that can be inserted into the DOM tree. The name of the element is <i>qName</i> and the namespace URI is <i>nsURI</i>. This function also sets <a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values (depending on <i>qName</i>).</p>
<p>If <i>qName</i> is an empty string, returns a null element.</p>
<p>See also <a href="qdomdocument.html#createElement">createElement</a>().</p>
<h3 class="fn"><a name="createEntityReference"></a><a href="qdomentityreference.html">QDomEntityReference</a> QDomDocument::createEntityReference ( const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Creates a new entity reference called <i>name</i> that can be inserted into the document, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().</p>
<p>If <i>name</i> is not a valid XML name, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().</p>
<h3 class="fn"><a name="createProcessingInstruction"></a><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a> QDomDocument::createProcessingInstruction ( const <a href="qstring.html">QString</a> &amp; <i>target</i>, const <a href="qstring.html">QString</a> &amp; <i>data</i> )</h3>
<p>Creates a new processing instruction that can be inserted into the document, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(). This function sets the target for the processing instruction to <i>target</i> and the data to <i>data</i>.</p>
<p>If <i>target</i> is not a valid XML name, or data if contains characters which cannot appear in a processing instruction, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().</p>
<h3 class="fn"><a name="createTextNode"></a><a href="qdomtext.html">QDomText</a> QDomDocument::createTextNode ( const <a href="qstring.html">QString</a> &amp; <i>value</i> )</h3>
<p>Creates a text node for the string <i>value</i> that can be inserted into the document tree, e.g&#x2e; using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored as character data of an XML document (even in the form of character references), the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation::InvalidDataPolicy</a>.</p>
<p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().</p>
<h3 class="fn"><a name="doctype"></a><a href="qdomdocumenttype.html">QDomDocumentType</a> QDomDocument::doctype () const</h3>
<p>Returns the document type of this document.</p>
<h3 class="fn"><a name="documentElement"></a><a href="qdomelement.html">QDomElement</a> QDomDocument::documentElement () const</h3>
<p>Returns the root element of the document.</p>
<h3 class="fn"><a name="elementById"></a><a href="qdomelement.html">QDomElement</a> QDomDocument::elementById ( const <a href="qstring.html">QString</a> &amp; <i>elementId</i> )</h3>
<p>Returns the element whose ID is equal to <i>elementId</i>. If no element with the ID was found, this function returns a <a href="qdomnode.html#isNull">null element</a>.</p>
<p>Since the QDomClasses do not know which attributes are element IDs, this function returns always a <a href="qdomnode.html#isNull">null element</a>. This may change in a future version.</p>
<h3 class="fn"><a name="elementsByTagName"></a><a href="qdomnodelist.html">QDomNodeList</a> QDomDocument::elementsByTagName ( const <a href="qstring.html">QString</a> &amp; <i>tagname</i> ) const</h3>
<p>Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that contains all the elements in the document with the name <i>tagname</i>. The order of the node list is the order they are encountered in a preorder traversal of the element tree.</p>
<p>See also <a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a>() and <a href="qdomelement.html#elementsByTagName">QDomElement::elementsByTagName</a>().</p>
<h3 class="fn"><a name="elementsByTagNameNS"></a><a href="qdomnodelist.html">QDomNodeList</a> QDomDocument::elementsByTagNameNS ( const <a href="qstring.html">QString</a> &amp; <i>nsURI</i>, const <a href="qstring.html">QString</a> &amp; <i>localName</i> )</h3>
<p>Returns a <a href="qdomnodelist.html">QDomNodeList</a> that contains all the elements in the document with the local name <i>localName</i> and a namespace URI of <i>nsURI</i>. The order of the node list is the order they are encountered in a preorder traversal of the element tree.</p>
<p>See also <a href="qdomdocument.html#elementsByTagName">elementsByTagName</a>() and <a href="qdomelement.html#elementsByTagNameNS">QDomElement::elementsByTagNameNS</a>().</p>
<h3 class="fn"><a name="implementation"></a><a href="qdomimplementation.html">QDomImplementation</a> QDomDocument::implementation () const</h3>
<p>Returns a <a href="qdomimplementation.html">QDomImplementation</a> object.</p>
<h3 class="fn"><a name="importNode"></a><a href="qdomnode.html">QDomNode</a> QDomDocument::importNode ( const <a href="qdomnode.html">QDomNode</a> &amp; <i>importedNode</i>, bool <i>deep</i> )</h3>
<p>Imports the node <i>importedNode</i> from another document to this document. <i>importedNode</i> remains in the original document; this function creates a copy that can be used within this document.</p>
<p>This function returns the imported node that belongs to this document. The returned node has no parent. It is not possible to import <a href="qdomdocument.html">QDomDocument</a> and <a href="qdomdocumenttype.html">QDomDocumentType</a> nodes. In those cases this function returns a <a href="qdomnode.html#isNull">null node</a>.</p>
<p>If <i>deep</i> is true, this function imports not only the node <i>importedNode</i> but its whole subtree; if it is false, only the <i>importedNode</i> is imported. The argument <i>deep</i> has no effect on <a href="qdomattr.html">QDomAttr</a> and <a href="qdomentityreference.html">QDomEntityReference</a> nodes, since the descendents of <a href="qdomattr.html">QDomAttr</a> nodes are always imported and those of <a href="qdomentityreference.html">QDomEntityReference</a> nodes are never imported.</p>
<p>The behavior of this function is slightly different depending on the node types:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Node Type</th><th>Behavior</th></tr></thead>
<tr valign="top" class="odd"><td><a href="qdomattr.html">QDomAttr</a></td><td>The owner element is set to 0 and the specified flag is set to true in the generated attribute. The whole subtree of <i>importedNode</i> is always imported for attribute nodes: <i>deep</i> has no effect.</td></tr>
<tr valign="top" class="even"><td><a href="qdomdocument.html">QDomDocument</a></td><td>Document nodes cannot be imported.</td></tr>
<tr valign="top" class="odd"><td><a href="qdomdocumentfragment.html">QDomDocumentFragment</a></td><td>If <i>deep</i> is true, this function imports the whole document fragment; otherwise it only generates an empty document fragment.</td></tr>
<tr valign="top" class="even"><td><a href="qdomdocumenttype.html">QDomDocumentType</a></td><td>Document type nodes cannot be imported.</td></tr>
<tr valign="top" class="odd"><td><a href="qdomelement.html">QDomElement</a></td><td>Attributes for which <a href="qdomattr.html#specified">QDomAttr::specified</a>() is true are also imported, other attributes are not imported. If <i>deep</i> is true, this function also imports the subtree of <i>importedNode</i>; otherwise it imports only the element node (and some attributes, see above).</td></tr>
<tr valign="top" class="even"><td><a href="qdomentity.html">QDomEntity</a></td><td>Entity nodes can be imported, but at the moment there is no way to use them since the document type is read-only in DOM level 2.</td></tr>
<tr valign="top" class="odd"><td><a href="qdomentityreference.html">QDomEntityReference</a></td><td>Descendents of entity reference nodes are never imported: <i>deep</i> has no effect.</td></tr>
<tr valign="top" class="even"><td><a href="qdomnotation.html">QDomNotation</a></td><td>Notation nodes can be imported, but at the moment there is no way to use them since the document type is read-only in DOM level 2.</td></tr>
<tr valign="top" class="odd"><td><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a></td><td>The target and value of the processing instruction is copied to the new node.</td></tr>
<tr valign="top" class="even"><td><a href="qdomtext.html">QDomText</a></td><td>The text is copied to the new node.</td></tr>
<tr valign="top" class="odd"><td><a href="qdomcdatasection.html">QDomCDATASection</a></td><td>The text is copied to the new node.</td></tr>
<tr valign="top" class="even"><td><a href="qdomcomment.html">QDomComment</a></td><td>The text is copied to the new node.</td></tr>
</table></p>
<p><a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>() <a href="qdomnode.html#replaceChild">QDomNode::replaceChild</a>() <a href="qdomnode.html#removeChild">QDomNode::removeChild</a>() <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>()</p>
<p>See also <a href="qdomelement.html#setAttribute">QDomElement::setAttribute</a>() and <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>().</p>
<h3 class="fn"><a name="nodeType"></a><a href="qdomnode.html#NodeType-enum">QDomNode::NodeType</a> QDomDocument::nodeType () const</h3>
<p>Returns <tt>DocumentNode</tt>.</p>
<h3 class="fn"><a name="setContent"></a>bool QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> &amp; <i>data</i>, bool <i>namespaceProcessing</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This function parses the XML document from the byte array <i>data</i> and sets it as the content of the document. It tries to detect the encoding of the document as required by the XML specification.</p>
<p>If <i>namespaceProcessing</i> is true, the parser recognizes namespaces in the XML file and sets the prefix name, local name and namespace URI to appropriate values. If <i>namespaceProcessing</i> is false, the parser does no namespace processing when it reads the XML file.</p>
<p>If a parse error occurs, this function returns false and the error message is placed in <tt>*</tt><i>errorMsg</i>, the line number in <tt>*</tt><i>errorLine</i> and the column number in <tt>*</tt><i>errorColumn</i> (unless the associated pointer is set to 0); otherwise this function returns true. The various error messages are described in the <a href="qxmlparseexception.html">QXmlParseException</a> class documentation. Note that, if you want to display these error messages to your application's users, they will be displayed in English unless they are explicitly translated.</p>
<p>If <i>namespaceProcessing</i> is true, the function <a href="qdomnode.html#prefix">QDomNode::prefix</a>() returns a string for all elements and attributes. It returns an empty string if the element or attribute has no prefix.</p>
<p>Text nodes consisting only of whitespace are stripped and won't appear in the <a href="qdomdocument.html">QDomDocument</a>. If this behavior is not desired, one can use the setContent() overload that allows a <a href="qxmlreader.html">QXmlReader</a> to be supplied.</p>
<p>If <i>namespaceProcessing</i> is false, the functions <a href="qdomnode.html#prefix">QDomNode::prefix</a>(), <a href="qdomnode.html#localName">QDomNode::localName</a>() and <a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>() return an empty string.</p>
<p>Entity references are handled as follows:</p>
<ul>
<li>References to internal general entities and character entities occurring in the content are included. The result is a <a href="qdomtext.html">QDomText</a> node with the references replaced by their corresponding entity values.</li>
<li>References to parameter entities occurring in the internal subset are included. The result is a <a href="qdomdocumenttype.html">QDomDocumentType</a> node which contains entity and notation declarations with the references replaced by their corresponding entity values.</li>
<li>Any general parsed entity reference which is not defined in the internal subset and which occurs in the content is represented as a <a href="qdomentityreference.html">QDomEntityReference</a> node.</li>
<li>Any parsed entity reference which is not defined in the internal subset and which occurs outside of the content is replaced with an empty string.</li>
<li>Any unparsed entity reference is replaced with an empty string.</li>
</ul>
<p><a href="qdomnode.html#prefix">QDomNode::prefix</a>() <a href="qstring.html#isNull">QString::isNull</a>() <a href="qstring.html#isEmpty">QString::isEmpty</a>()</p>
<p>See also <a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>().</p>
<h3 class="fn"><a name="setContent-2"></a>bool QDomDocument::setContent ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, bool <i>namespaceProcessing</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the string <i>text</i>, returning true if the content was successfully parsed; otherwise returns false. Since <i>text</i> is already a Unicode string, no encoding detection is done.</p>
<h3 class="fn"><a name="setContent-3"></a>bool QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * <i>dev</i>, bool <i>namespaceProcessing</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the IO device <i>dev</i>, returning true if the content was successfully parsed; otherwise returns false.</p>
<h3 class="fn"><a name="setContent-4"></a>bool QDomDocument::setContent ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the string <i>text</i>, returning true if the content was successfully parsed; otherwise returns false. Since <i>text</i> is already a Unicode string, no encoding detection is performed.</p>
<p>No namespace processing is performed either.</p>
<h3 class="fn"><a name="setContent-5"></a>bool QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> &amp; <i>buffer</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the byte array <i>buffer</i>, returning true if the content was successfully parsed; otherwise returns false.</p>
<p>No namespace processing is performed.</p>
<h3 class="fn"><a name="setContent-6"></a>bool QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * <i>dev</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the IO device <i>dev</i>, returning true if the content was successfully parsed; otherwise returns false.</p>
<p>No namespace processing is performed.</p>
<h3 class="fn"><a name="setContent-7"></a>bool QDomDocument::setContent ( <a href="qxmlinputsource.html">QXmlInputSource</a> * <i>source</i>, <a href="qxmlreader.html">QXmlReader</a> * <i>reader</i>, <a href="qstring.html">QString</a> * <i>errorMsg</i> = 0, int * <i>errorLine</i> = 0, int * <i>errorColumn</i> = 0 )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the <a href="qxmlinputsource.html">QXmlInputSource</a> <i>source</i> and parses it with the <a href="qxmlreader.html">QXmlReader</a> <i>reader</i>, returning true if the content was successfully parsed; otherwise returns false.</p>
<p>This function doesn't change the features of the <i>reader</i>. If you want to use certain features for parsing you can use this function to set up the reader appropriately.</p>
<p>See also <a href="qxmlsimplereader.html">QXmlSimpleReader</a>.</p>
<h3 class="fn"><a name="toByteArray"></a><a href="qbytearray.html">QByteArray</a> QDomDocument::toByteArray ( int <i>indent</i> = 1 ) const</h3>
<p>Converts the parsed document back to its textual representation and returns a <a href="qbytearray.html">QByteArray</a> containing the data encoded as UTF-8.</p>
<p>This function uses <i>indent</i> as the amount of space to indent subelements.</p>
<p>See also <a href="qdomdocument.html#toString">toString</a>().</p>
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> QDomDocument::toString ( int <i>indent</i> = 1 ) const</h3>
<p>Converts the parsed document back to its textual representation.</p>
<p>This function uses <i>indent</i> as the amount of space to indent subelements.</p>
<h3 class="fn"><a name="operator-eq"></a>QDomDocument &amp; QDomDocument::operator= ( const QDomDocument &amp; <i>x</i> )</h3>
<p>Assigns <i>x</i> to this DOM document.</p>
<p>The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use <a href="qdomnode.html#cloneNode">cloneNode</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
